/**
 * Created by weikexin .
 * description:
 **/
import { HTTP } from '../util/http'

class Bidding extends HTTP {
  biddingList (params={}, success) {
    let url = 'BiddingManagement/queryBiddingManagementPage'
    let data = Object.assign({},
      params,
      {
        count: 10,
        rnd: 666
      })
    this.request({
      url: url,
      method: 'POST',
      urlData: data,
      success
    })
  }

  publish (params={}, success, fail) {
    let url = 'BiddingManagement/save'
    let data = Object.assign({},
      params,
      {
        userName: wx.getStorageSync('userInfo').user_name || 0
      })
    this.request({
      url: url,
      method: 'POST',
      data: data,
      urlData: {
        userId: wx.getStorageSync('userInfo').user_id || 0
      },
      success,
      fail
    })
  }

  update (params={}, success, fail) {
    let url = 'BiddingManagement/updateById'
    let data = Object.assign({},
      params,
      {
      })
    this.request({
      url: url,
      method: 'POST',
      data: data,
      urlData: {
        userId: wx.getStorageSync('userInfo').user_id || 0
      },
      success,
      fail
    })
  }

  delete(params, success, fail) {
    let url = 'BiddingManagement/deleteById'
    let data = Object.assign({},
        params,
        {})
    this.request({
        method: 'POST',
        url: url,
        urlData: data,
        success,
        fail
    })
  }


  detail (params, success) {
    let url = 'BiddingManagement/queryDetailById'
    let data =  Object.assign({},
      params,
      {
        userId: wx.getStorageSync('userInfo').user_id || 0
      })
    this.request({
      url: url,
      data: data,
      success
    })
  }

  projects (params, success) {
    let url = 'DataDictionary/queryDataByType'
    let data =  Object.assign({},
      params,
      {
        userId: wx.getStorageSync('userInfo').user_id || 0
      })
    this.request({
      url: url,
      data: data,
      success
    })
  }

  delivery (params, success) {
    let url = 'BiddingManagement/sendTender'
    let data =  Object.assign({},
      params,
      {
        userId: wx.getStorageSync('userInfo').user_id || 0
      })
    this.request({
      url: url,
      data: data,
      success
    })
  }

  getReceivedBidding (params, success) {
    let url = 'BiddingManagement/receiveTenderInfo'
    let data =  Object.assign({},
      params,
      {
        count: 10
      })
    this.request({
      url: url,
      data: data,
      success,
      method: 'POST'
    })
  }

  updateReadState (params, success) {
    let url = 'BiddingManagement/updateReadState'
    let data =  Object.assign({},
      params,
      {
        userId: wx.getStorageSync('userInfo').user_id || 0
      })
    this.request({
      url: url,
      data: data,
      success
    })
  }

}
export { Bidding }
